import hyRequest from '@/services/index'
import type { IUser, IUserInfo, IUserResponse } from './type'

// 查询用户列表
export function postUsersListData(data: IUser) {
  return hyRequest.post<IUserResponse>({
    url: '/users/list',
    data
  })
}

// 根据id删除用户
export function deleteUserById(id: number) {
  return hyRequest.delete<any>({
    url: `/users/${id}`
  })
}

// 新建用户
export function newUserData(userInfo: IUserInfo) {
  return hyRequest.post<any>({
    url: '/users',
    data: userInfo
  })
}

// 编辑用户
export function editUserData(id: number, userInfo: IUserInfo) {
  return hyRequest.patch<any>({
    url: `/users/${id}`,
    data: userInfo
  })
}
